package com.woniuxy.carlife.carlifeuserweb.controller;


import cn.hutool.core.util.ObjectUtil;
import com.woniuxy.carlife.carlifecommonsweb.exception.CarlifeGlobalException;
import com.woniuxy.carlife.carlifecommonsweb.responsetemplate.Result;
import com.woniuxy.carlife.carlifecommonsweb.responsetemplate.StatusCode;
import com.woniuxy.carlife.carlifecommonsweb.util.CopyUtil;
import com.woniuxy.carlife.carlifecommonsweb.util.JwtUtil;
import com.woniuxy.carlife.carlifeusermodel.dto.CarbrandDto;
import com.woniuxy.carlife.carlifeuserweb.entity.Carbrand;
import com.woniuxy.carlife.carlifeuserweb.service.CarbrandService;
import com.woniuxy.carlife.carlifeuserweb.util.StatusMessageEnum;
import io.jsonwebtoken.Claims;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zjq
 * @ClassName:CarbrandController
 * @Description:
 * @date 2021/4/6 20:02
 **/

//@RestController
//@RequestMapping("/carbrand")
//@Api(tags = "查询汽车品牌")//用于描述接口类的相关信息，作用于类上
public class CarbrandController {

    @Resource
    CarbrandService carbrandService;

//    /*
//     * 功能描述〈查询汽车品牌〉
//     * @author:zjq
//     * @param:
//     * @return:
//     * @Date 2021/4/10 17:05
//     * @throws
//     */
//    @ApiOperation(value = "查询汽车型号（解析token获取）")
//    @GetMapping("/ordinary/findCarbrand")
//    public Result findCarbrand() {
//        ServletRequestAttributes sra =
//                (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
//        String token = sra.getRequest().getHeader("token");
//        JwtUtil jwtUtil = new JwtUtil();
//        Claims claims = jwtUtil.parseTokenOrdinary(token);
//        if (claims == null) {
//
//            return new Result(false, StatusCode.ERROR, StatusMessageEnum.NOT_LOGGED_IN.toString());
//        }
//
//        List<Carbrand> carbrand = carbrandService.findCarbrand();
//        if (ObjectUtil.isNull(carbrand)) {
//            return new Result(false, StatusCode.ERROR, StatusMessageEnum.QUERY_IS_EMPTY.toString());
//        }
//
//        List<CarbrandDto> carbrandList = CopyUtil.getList(carbrand, CarbrandDto.class);
//
//        return new Result(true, StatusCode.OK, StatusMessageEnum.SEARCH_SUCCESSFUL.toString(), carbrandList);
//    }

}

